# ifndef DEF_AI
# define DEF_AI

# include "Source.h"

# include "Module.h"

/*
*	This class calculates everything needed in the game.
*/

class AI : public Module
{
	public:

	AI( Game*);
	~AI();

	void setWindow( Ogre::RenderWindow*);
	void setWorld( World*);

	void init( Renderer*,GUI*);
	void loadWorld( const std::string&);
	void unloadWorld();

	void oneFrame();

	void findDirection( Enemy*);
	void findDirection( Hero*, Enemy*);

	void heroDistance( Enemy*);

	private:

	virtual void handleEvents();

	void mouseClicked( float, float);
	void mouseRequest( float, float);

	Ogre::Vector3 getCoordinatesMouse( float, float);

	void pathFinding( Personage*, const Ogre::Vector3&);
	int findNavMesh( const Ogre::Vector3&);
	bool isInsidePolygon( NavMeshPol*, const Ogre::Vector2&);
	int find( const std::deque<Node*>&, const NavMeshPol*);
	const Ogre::Vector2& findMidPoint( const NavMeshPol*, const NavMeshPol*);

	Ogre::RaySceneQuery* myRaySceneQuery;
	
	Renderer* myRenderer;
	GUI* myGUI;

	Ogre::RenderWindow* myWindow;
	
	World* myWorld;
	std::vector<NavMeshPol*> myNavMesh;

	Hero* myHero;
	Map* myMap;

	Enemy* myEnemyHighlight;
};

# endif